package info.mikrotubula.utils;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;


import javax.faces.application.FacesMessage;
import javax.faces.application.FacesMessage.Severity;


public class MessageHandler {
    private static final long serialVersionUID = -6479897299239746841L;
    private String messageHeader;
    private String messageImage;
    private Severity severityLevel;

    public MessageHandler() {
        messageHeader = null;

        // See if there are messages queued for the page
        severityLevel = FacesContext.getCurrentInstance().getMaximumSeverity();

        if (null != severityLevel) {
            if (severityLevel.compareTo(FacesMessage.SEVERITY_ERROR) == 0) {
                messageHeader = null;
                messageImage = "static/images/error.gif";
            } else if (severityLevel.compareTo(FacesMessage.SEVERITY_INFO) == 0) {
                messageHeader = null;
                messageImage = "static/images/information.gif";
            } else if (severityLevel.compareTo(FacesMessage.SEVERITY_WARN) == 0) {
                messageHeader = null;
                messageImage = "static/images/warning_ball.gif";
            } else if (severityLevel.compareTo(FacesMessage.SEVERITY_FATAL) == 0) {
                messageHeader = null;
                messageImage = "static/images/error.gif";
            }
        }
    }

    public String getMessageHeader() {
        return messageHeader;
    }

    public String getMessageImage() {
        return messageImage;
    }
}
